package connection;

import java.io.IOException;
import java.net.Socket;

public class ControllerConnectionOut extends ConnectionOut {

	public ControllerConnectionOut(Socket socket, Relay relay) {
		super(socket, relay);
	}

	@Override
	protected void handleMessage() {
		ControllerMessage msg = relay.getControllerMessage();
		if (msg != null) {
			try {
				dos.write(msg.getLane());
				dos.write(msg.getLightState());
			} 
			catch (IOException e) {
				e.printStackTrace();
			}
		}
		else {
			try {
				Thread.sleep(100);
			} 
			catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
